Modify the project based on the previous Hello World or E2PROM Vivado project:
The schematic is as follows: It involves two keys and two LEDs connected to the PS MIO, two keys and two LEDs connected to the PS EMIO, and one EMIO IO used to control the buzzer.
To configure the PS side, directly click on GPIO MIO. By default, all pins are selected. We need to use PS_KEY0 corresponding to MIO0, PS_KEY1 corresponding to MIO11, PS_LED0 corresponding to MIO7, and PS_LED1 corresponding to MIO8.
There are five IOs that need to be set as EMIO, corresponding to two keys, two LEDs, and one buzzer. Therefore, just select 5 during configuration. If you select more, you must also configure constraints for the extra pins in the subsequent pin constraints:
Click OK. Similarly, right-click on GPIO_0 and click Make External. The software will automatically generate external pins corresponding to the EMIO interface in the top-level module:
The next steps are the same as for IIC, with the only difference being the pin constraints. Here, I will use the checkbox method to configure the pin constraints, as derived from the schematic:
In the interface, [0], [1], [2], [3], and [4] correspond to PL_KEY0, PL_KEY1, PL_LED0, PL_LED1, and BEEP, respectively.
After that, sequentially run synthesis, implementation, and generate bitstream, and finally generate a new .xsa file:
In Vitis, update the platform project: Right-click the created platform project, click Update Hardware Specification, select the .xsa file path. The following pop-up box will appear; click OK, which indicates a successful update. The platform project will show as "out of date," at which point you need to rebuild the platform project.
Similarly, click File-->new-->Application Project;
Select an empty .c project;
Then, add the .c file.
The program implements four keys to control four LEDs respectively. When a key is pressed, the corresponding LED lights up; when the key is released, the LED turns off.
It should be noted that the pin numbers for MIO are 0-53, and the pin numbers for EMIO start from 54. Since 5 pins were extended for EMIO this time, the corresponding numbers are 54-58
x// PS key and LED pin definitions// PS LED0 pin: MIO7// PS LED1 pin: MIO8// PS KEY0 pin: MIO0// PS KEY1 pin: MIO11
// 0~53 is for MIO, EMIO starts from 54// EMIO pin definitions// EMIO KEY0 pin// EMIO KEY1 pin// EMIO LED0 pin// EMIO LED1 pin// EMIO BEEP pin
After the project is successfully compiled, connect the development board's JTAG to the computer using a Type-C USB cable. Use another Type-C USB cable to connect the development board's PS UART to the computer.
On the computer, open the serial debugging tool MobaXterm and establish a connection with the development board's PS UART.
In Vitis, enter debug mode: Under Debug As, select the first option. Running at full speed will allow you to see debug information through the serial port, and you will observe the corresponding phenomena on the development board.
After running, pressing or releasing the corresponding keys will print information about the key press or release in the serial port, and the corresponding LEDs will light up or turn off.